


clear 
set scheme lean2, permanent
global pm = char(177)
set more off

gl date = c(current_date)
if c(os) == "MacOSX" gl user "/Users/`c(username)'"
else if c(os) == "Windows" gl user "C:\Users\\`c(username)'"
else if c(os) == "Unix" gl user "/usr/`c(username)'"
di "$user

set graphics on  
 
global path_data_processed "\data\processed"
global path_output "\data\output"

 
clear all
set more off

cd "$path_data_processed"
use "experimentRNall.dta", clear

cd "$path_output"
 
 
			   loc experiments "prior prior "

		 	   
			   
preserve

clear all
eststo clear
estimates drop _all

set obs 10
qui gen x = 1
qui gen y = 1

loc columns = 0

foreach choice in `experiments' {

    loc ++columns
    qui eststo col`columns': reg x y

}

restore


/* Statistics */

loc colnum = 1
loc colnames ""

foreach var of varlist finlit_index republican democrat unemp_rate2016 prior_conf  {
gen mis`var'= `var'==.
replace `var'=0 if `var'==.
}
  
replace log_income=0 if inc_NR==1

la var ever_unemployed_imp "Ever unemployed"


***Pooled Sample

*** Column 1:

     reg prior  atleast_bachelor
    sigstar atleast_bachelor, prec(3)
    estadd loc thisstat2 = "`r(bstar)'": col1
    estadd loc thisstat3 = "`r(sestar)'": col1
	
	
     reg prior female
	
    sigstar female, prec(3)
    estadd loc thisstat5 = "`r(bstar)'": col1
    estadd loc thisstat6 = "`r(sestar)'": col1	
	
     reg prior age
	
	sigstar age, prec(3)
    estadd loc thisstat8 = "`r(bstar)'": col1
    estadd loc thisstat9 = "`r(sestar)'": col1	
	
     reg prior agesq
	
	sigstar agesq, prec(3)
    estadd loc thisstat11 = "`r(bstar)'": col1
    estadd loc thisstat12 = "`r(sestar)'": col1	
	
     reg prior log_inc
	
	sigstar log_inc, prec(3)
    estadd loc thisstat14 = "`r(bstar)'": col1
    estadd loc thisstat15 = "`r(sestar)'": col1	
	
     reg prior republican
	
	sigstar republican, prec(3)
    estadd loc thisstat17 = "`r(bstar)'": col1
    estadd loc thisstat18 = "`r(sestar)'": col1	
	
	reg prior democrat

	sigstar democrat, prec(3)
    estadd loc thisstat20 = "`r(bstar)'": col1
    estadd loc thisstat21 = "`r(sestar)'": col1	
	
     reg prior finlit_index
	
	sigstar finlit_index, prec(3)
    estadd loc thisstat23 = "`r(bstar)'": col1
    estadd loc thisstat24 = "`r(sestar)'": col1		
	
     reg prior unemp_rate2016
	
	sigstar unemp_rate2016, prec(3)
    estadd loc thisstat26 = "`r(bstar)'": col1
    estadd loc thisstat27 = "`r(sestar)'": col1		
	
     reg prior ever_unemployed_imp
	
	sigstar ever_unemployed_imp, prec(3)
    estadd loc thisstat29 = "`r(bstar)'": col1
    estadd loc thisstat30 = "`r(sestar)'": col1		
	
	
     reg prior 	prior_conf
						
	sigstar prior_conf, prec(3)
    estadd loc thisstat32 = "`r(bstar)'": col1
    estadd loc thisstat33 = "`r(sestar)'": col1		
					

*** Column 2:


     reg prior female age agesq atleast_bachelor log_inc republican democrat finlit_index midwest south west unemp_rate2016 ever_unemployed_imp prior_conf inc_NR mis*, r

    sigstar atleast_bachelor, prec(3)
    estadd loc thisstat2 = "`r(bstar)'": col2
    estadd loc thisstat3 = "`r(sestar)'": col2
	
    sigstar female, prec(3)
    estadd loc thisstat5 = "`r(bstar)'": col2
    estadd loc thisstat6 = "`r(sestar)'": col2	
	
	sigstar age, prec(3)
    estadd loc thisstat8 = "`r(bstar)'": col2
    estadd loc thisstat9 = "`r(sestar)'": col2	
	
	sigstar agesq, prec(3)
    estadd loc thisstat11 = "`r(bstar)'": col2
    estadd loc thisstat12 = "`r(sestar)'": col2	
	
	sigstar log_inc, prec(3)
    estadd loc thisstat14 = "`r(bstar)'": col2
    estadd loc thisstat15 = "`r(sestar)'": col2	
	
	sigstar republican, prec(3)
    estadd loc thisstat17 = "`r(bstar)'": col2
    estadd loc thisstat18 = "`r(sestar)'": col2	
	
	sigstar democrat, prec(3)
    estadd loc thisstat20 = "`r(bstar)'": col2
    estadd loc thisstat21 = "`r(sestar)'": col2	
	
	sigstar finlit_index, prec(3)
    estadd loc thisstat23 = "`r(bstar)'": col2
    estadd loc thisstat24 = "`r(sestar)'": col2		
	
	sigstar unemp_rate2016, prec(3)
    estadd loc thisstat26 = "`r(bstar)'": col2
    estadd loc thisstat27 = "`r(sestar)'": col2		
	
	sigstar ever_unemployed_imp, prec(3)
    estadd loc thisstat29 = "`r(bstar)'": col2
    estadd loc thisstat30 = "`r(sestar)'": col2		

	sigstar prior_conf, prec(3)
    estadd loc thisstat32 = "`r(bstar)'": col2
    estadd loc thisstat33 = "`r(sestar)'": col2		
				
		
	
*************************column 2***********************************************


	
	
	
	qui sum `choice'
    estadd loc thisstat35 = r(N): col1
    estadd loc thisstat35 = r(N): col2

	
    loc ++colnum
    loc colnames "`colnames' `"`: var la `choice''"'"
	
	
loc rowlabels " " " "High education" " " " " "Female" " " " " "Age" " " " " "Age squared" " " " " "Log income" " " " " "Republican" " " " " "Democrat" " " " " "Financial literacy" " " " " "County unemployment" " " " " "Ever unemployed" " " " " "Confidence in prior" " " " " "Observations" "
loc rowstats ""

forval i = 1/35 {
    loc rowstats "`rowstats' thisstat`i'"
}



esttab * using "correlatesprior.tex", replace cells(none) booktabs nonotes nomtitles /*nonum*/ compress alignment(c) nogap noobs nobaselevels label stats(`rowstats', labels(`rowlabels')) ///
      mgroups("\shortstack{Probability of\\a recession\\(univariate)}" "\shortstack{Probability of\\a recession\\(multivariate)}" , pattern(1 1 1 1 1 1 1 1) prefix(\multicolumn{@span}{c}{) suffix(})  erepeat(\cmidrule(lr){@span}))
		
	
eststo clear	
	
